home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Power 1997 December
/
MACPOWER-1997-12.ISO.7z
/
MACPOWER-1997-12.ISO
/
AMUG
/
PROGRAMMING
/
Raven 1.2.sit
/
Raven 1.2
/
Source
/
Foundation
/
Common
/
ZBestFitAllocator.h
< prev
next >
Wrap
Text File
|
1997-06-17
|
2KB
|
79 lines
/*
* File: ZBestFitAllocator.h
* Summary: An allocator that uses the ODMemMgr from MacApp.
* Written by: Jesse Jones
*
* Abstract: This allocator is about as fast as TSimpleAllocator but does
* a much better job giving memory back to the OS. However if your
* app makes heavy use of doubles you may want to use TSimpleAllocator
* since BestFitHeap only aligns blocks to 4-byte boundaries.
*
* Copyright ゥ 1997 Jesse Jones.
* For conditions of distribution and use, see copyright notice in ZTypes.h
*
* Change History (most recent first):
*
* <-> 1/30/97 JDJ Created
*/
#pragma once
#include <MemMgr.h>
#include <ZAllocator.h>
//-----------------------------------
// Forward References
//
class BestFitHeap;
// ===================================================================================
// class TBestFitAllocator
// ===================================================================================
class TBestFitAllocator : public TAllocator {
typedef TAllocator Inherited;
//-----------------------------------
// Initialization/Destruction
//
public:
virtual ~TBestFitAllocator();
TBestFitAllocator(ulong initialSize, ulong poolSize, ulong hugeSize = 0,
MMHeapLocation heap = kMMAppMemory);
// Heap will start with initialSize bytes. When the heap is
// exhausted a new pool with poolSize bytes will be allocated.
// Blocks larger than hugeSize are always allocated using NewPtr
// and never reused (0 means poolSize/4).
//-----------------------------------
// Inherited API
//
public:
virtual void* Allocate(ulong bytes);
virtual void Deallocate(void* block);
virtual ulong GetHeapSize() const;
virtual ulong GetPoolCount() const;
virtual ulong GetBlockSize(const void* ptr) const;
virtual ulong GetTotalBlockSize(const void* ptr) const;
#if DEBUG
virtual void ValidateBlock(const void* ptr) const;
virtual void ValidateHeap(BlockValidateHook hook = nil, void* refCon = nil) const;
#endif
//-----------------------------------
// Member Data
//
protected:
BestFitHeap* mHeap;
};